<template>
  <div>
    <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
      <el-form-item label="上级类型">
        <el-select v-model="formLabelAlign.parentId" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.id"
            :label="item.typeName"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="类型名称">
        <el-input v-model="formLabelAlign.typeName"></el-input>
      </el-form-item>
      <el-form-item label="层级">
        <el-input v-model="formLabelAlign.levelId"></el-input>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="formLabelAlign.status" placeholder="请选择">
          <el-option
            v-for="item in statusList"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <el-button size="mini" @click="doadd()">添加</el-button>
  </div>

</template>

<script>
import { addType, findparentId, getList } from '../../../api/wms/type'

export default {
  name: 'addindex',
  data() {
    return {
      labelPosition:'right',
      tableData: [],
      formLabelAlign:{},
      multipleSelection: [],
      options:[],
      statusList:[
        {
          value: 0,
          label: '无效'
        },
        {
          value: 1,
          label: '有效'
        }
      ],
    }
  },
  created() {
    this.getOptions();
  },
  methods: {
    getOptions(){
      findparentId().then((res)=>{
        this.options = res.data;
      })
    },
    doadd(){
      addType(this.formLabelAlign).then((res)=>{
        this.$message({
          message: '添加成功',
          type: 'success'
        });
        this.$router.push({path:'/wms/type'})
      })
    }
  }
}
</script>

<style scoped>

</style>
